package com.example.erp.controller.permission;

import com.example.erp.dto.permissionDTO.UserDTO;
import com.example.erp.dto.permissionDTO.UserEditPwdDTO;
import com.example.erp.pojo.permission.User;
import com.example.erp.service.permission.UserService;
import com.example.erp.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/admin/permission/user")
public class UserController {
    @Autowired
    private UserService UserService;

    @GetMapping("/list")
    private Result list(UserDTO userDTO) {
        return UserService.list(userDTO);
    }

    @PostMapping("/add")
    private Result add(@RequestBody User user) {
        return UserService.add(user);
    }

    @PostMapping("/edit")
    private Result edit(@RequestBody User user) {
        return UserService.edit(user);
    }

    @PostMapping("/update-pwd")
    private Result updatePwd(@RequestBody UserEditPwdDTO userEditPwdDTO,@RequestHeader("token") String token) {
        return UserService.editPwd(userEditPwdDTO,token);
    }

    @DeleteMapping("/remove")
    private Result remove(@RequestBody List<Long> ids) {
        return UserService.remove(ids);
    }


}
